function msg(title, duration = 1500) {
  uni.showToast({
    title: title,
    icon: 'none',
    duration: duration
  });
}

function goto(url = '', type = 'to') {
  if (typeof url === 'number') {
    uni.navigateBack({
      delta: url
    });
  } else if (typeof url === 'string') {
    if (url == '') {
      msg('暂未开放，敬请期待');
    }
    if (type == 'to') {
      uni.navigateTo({
        url: url
      });
    }
    if (type == 'tab') {
      uni.switchTab({
        url: url
      });
    }
    if (type == 'redirect') {
      uni.redirectTo({
        url: url
      });
    }
    if (type == 'relaunch') {
      uni.reLaunch({
        url: url
      });
    }
  }
}

const install = Vue => {
  Vue.prototype.$msg = msg
  Vue.prototype.$goto = goto
}

export default {
  install
}